const db = require('../db/index.js')
// 导入加密中间件
const bcrypt = require('bcryptjs')
// 导入nodejs的crypto生成onlyid
const crypto = require('crypto')
// 处理文件路径
fs = require('fs')



// 创建购物车
exports.createCart = (req, res) => {
    const { id, goods_id } = req.body;
    console.log(req.body, 777888);

    const sql = 'INSERT INTO cart (id, goods_id) VALUES (?, ?)';
    db.query(sql, [id, goods_id], (err, result) => {
        if (err) return res.cc(err);

        res.send({
            status: 0,
            message: '订单创建成功',
        });
    });
};


// 获取购物车
exports.getCart = (req, res) => {
	const sql = 'select * from cart where id = ?'
	db.query(sql, req.body.id, (err, result) => {
		if (err) return res.cc(err)
		res.send(result)
	})
}



